package pda;

import org.junit.jupiter.api.Test;

import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertTrue;

/**
 * @author haoly
 * @title PDARuleTest
 * @date 2025/4/21 10:25
 * @description TODO
 */
public class PDARuleTest {
    @Test
    public void testAppliesTo(){
        PDARule<Integer> rule = new PDARule<>(1, '(', 2, '$', "b$");
        System.out.println(rule);

        Stack<Character> stack = new Stack<>(Arrays.asList('$'));
        PDAConfiguration<Integer> configuration = new PDAConfiguration<>(1, stack);

        System.out.println(configuration);

        assertTrue(rule.appliesTo(configuration, '('));

    }
    @Test
    public void testFollow(){
        PDARule<Integer> rule = new PDARule<>(1, '(', 2, '$', "b$");
        System.out.println(rule);

        Stack<Character> stack = new Stack<>(Arrays.asList('$'));
        PDAConfiguration<Integer> configuration = new PDAConfiguration<>(1, stack);

        System.out.println(configuration);

        assertTrue(rule.appliesTo(configuration, '('));

        System.out.println(rule.follow(configuration));

    }

}
